package com.sh.data.engine.domain.normalization.standard.model.domain;

import com.sh.data.engine.repository.dao.normalization.standard.entity.DictionaryMappingReportEntity;
import lombok.Builder;
import lombok.Data;

import java.util.List;

import static java.lang.Math.toIntExact;

/**
 * @Version 1.0 @Author:xinyan @Date:2022/7/26 @Content:
 */
@Data
@Builder(toBuilder = true)
public class FormCheckDomain {

    private Integer checkFormTotal;

    private Integer standard;

    private Integer disStandard;

    public static FormCheckDomain getFormStatistics(List<DictionaryMappingReportEntity> list) {
        return FormCheckDomain.builder()
            .checkFormTotal(toIntExact(list.size()))
            .standard(
                toIntExact(list.stream().filter(DictionaryMappingReportEntity::checkIsHitCount).count()))
            .disStandard(
                toIntExact(list.stream().filter(DictionaryMappingReportEntity::checkDisHitCount).count()))
            .build();
    }

    public static FormCheckDomain newStatDomain(List<DictionaryMappingReportEntity> reportList) {

        return FormCheckDomain.getFormStatistics(reportList);
    }
}
